package extended

import (
	"jvmgo/instructions/base"
	"jvmgo/rtda"
)

type IFNULL struct {
	base.BranchInstruction
}

// the unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is calculated to be (branchbyte1 << 8) | branchbyte2.
func (self *IFNULL) Execute(frame *rtda.Frame) {
	val := frame.OperandStack().PopRef()
	if val == nil {
		base.Branch(frame, self.Offset)
	}
}

type IFNONNULL struct {
	base.BranchInstruction
}

func (self *IFNONNULL) Execute(frame *rtda.Frame) {
	val := frame.OperandStack().PopRef()
	if val != nil {
		base.Branch(frame, self.Offset)
	}
}
